Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Nov 4, 2025

Add MCP server API reference documentation

Summary

Created comprehensive API reference documentation for two Fern Docs endpoints that enable MCP (Model Context Protocol) agents to authenticate and search documentation:

  1. GET /api/fern-docs/get-jwt - Exchanges a Fern API key for a JWT token
  2. GET /api/fern-docs/search/v2/key - Retrieves Algolia search credentials (supports both API key and JWT auth)

The documentation includes:

  • New "MCP server for your site" page under Ask Fern → Features
  • Detailed request/response specifications with code examples
  • Environment-specific behavior notes (local/self-hosted/production)
  • Proper Fern API definition at fern/apis/fern-docs-mcp/ with OpenAPI 3.1.0 spec
  • Inline YAML spec and separate JSON file for programmatic access

Documentation approach: Created by examining actual route implementations in fern-platform/packages/fern-docs/bundle/src/app/[host]/[domain]/api/fern-docs/ to ensure accuracy of headers, authentication flows, and error responses.

Review & Testing Checklist for Human

  • Test the complete authentication flow end-to-end: Run the documented curl commands with a real Fern API key against an actual protected docs site. The most critical thing to verify is the header syntax - specifically whether FERN_API_KEY:${VAR} (with colon directly after header name) is correct or if it should be FERN_API_KEY: ${VAR} (with space after colon). The code uses these as custom header names, but the curl syntax may differ.

  • Verify the CLI command: The docs reference fern token for generating API keys. Confirm this is the correct command (not fern generate token) by checking the actual CLI behavior or canonical CLI documentation.

  • Validate the OpenAPI specification: The fern/apis/fern-docs-mcp/openapi.json file was hand-written based on code inspection. Test it with an OpenAPI validator and consider generating a client from it to verify the schema accuracy, especially for:

    • The roles field in responses (conditionally present based on auth method)
    • Error response formats (some may be plain strings vs JSON objects)
    • Required vs optional fields in response schemas
  • Test environment restrictions: Verify the documented behaviors for local preview (400 errors), self-hosted environments (400 for JWT, mock credentials for search), and preview URLs actually match the implementation. These were inferred from code but not tested.

  • Check if the OpenAPI spec should be surfaced in navigation: The API definition exists at fern/apis/fern-docs-mcp/ but isn't wired into the Ask Fern product navigation as a separate API Reference section. Determine if this is intentional or if an api: block should be added to ask-fern.yml to make it discoverable in the sidebar.

Notes

  • Used placeholder domain docs.example.com and plant-themed examples (botanist, seedling, aloe-bot-42) per style guidelines
  • Fixed all Vale linting issues: "API Reference" capitalization, contractions, defined SSO acronym
  • The inline YAML spec in the docs page duplicates the JSON file content for readability; consider removing one if redundant
  • Link to Devin run: https://app.devin.ai/sessions/42e2516d7d12417e94a3726d3990312e
  • Requested by: [email protected]

@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

- Create new MCP server documentation page under Ask Fern features
- Add comprehensive API reference for get-jwt and search/v2/key endpoints
- Include OpenAPI 3.1 specification with downloadable YAML file
- Update navigation to include MCP server page
- Replace JWT auth flow in api-get-started.mdx with link to MCP docs

Co-Authored-By: [email protected] <[email protected]>
- **Automated testing**: Programmatically verify documentation content and search functionality
- **Custom integrations**: Build tools that need to access protected documentation content

## API reference
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[FernStyles.Reject] Use 'API Reference' instead of 'API reference'.


| Status | Description |
|--------|-------------|
| 400 | JWT generation is not accessible in local preview mode |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[Microsoft.Contractions] Use 'isn't' instead of 'is not'.

| Status | Description |
|--------|-------------|
| 400 | JWT generation is not accessible in local preview mode |
| 400 | JWT generation is not supported in self-hosted environments |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[Microsoft.Contractions] Use 'isn't' instead of 'is not'.

|--------|-------------|
| 400 | JWT generation is not accessible in local preview mode |
| 400 | JWT generation is not supported in self-hosted environments |
| 400 | SSO/WorkOS authentication is not supported by this endpoint |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'SSO' has no definition.

|--------|-------------|
| 400 | JWT generation is not accessible in local preview mode |
| 400 | JWT generation is not supported in self-hosted environments |
| 400 | SSO/WorkOS authentication is not supported by this endpoint |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[Microsoft.Contractions] Use 'isn't' instead of 'is not'.

| 400 | SSO/WorkOS authentication is not supported by this endpoint |
| 401 | Missing `FERN_API_KEY` header |
| 401 | Invalid API key |
| 403 | API key does not belong to the organization that owns this domain |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[Microsoft.Contractions] Use 'doesn't' instead of 'does not'.


| Status | Description |
|--------|-------------|
| 400 | Search key is not accessible in local preview mode |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[Microsoft.Contractions] Use 'isn't' instead of 'is not'.

| Status | Description |
|--------|-------------|
| 400 | Search key is not accessible in local preview mode |
| 400 | Search is not supported for preview URLs (unless explicitly enabled) |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[Microsoft.Contractions] Use 'isn't' instead of 'is not'.

| 400 | Search key is not accessible in local preview mode |
| 400 | Search is not supported for preview URLs (unless explicitly enabled) |
| 401 | Invalid API key |
| 403 | API key does not belong to the organization that owns this domain |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[Microsoft.Contractions] Use 'doesn't' instead of 'does not'.

- Remove empty fern/apis/fern-docs-mcp directory causing CI failure
- Change 'API reference' to 'API Reference' per FernStyles.Reject rule
- Use contractions (isn't, doesn't) per Microsoft.Contractions
- Define SSO (Single sign-on) on first use per FernStyles.Acronyms
- Fix broken link in api-get-started.mdx to use correct path
- Remove download link to openapi.yaml (file not hosted)

Co-Authored-By: [email protected] <[email protected]>
|--------|-------------|
| 400 | JWT generation isn't accessible in local preview mode |
| 400 | JWT generation isn't supported in self-hosted environments |
| 400 | Single sign-on (SSO)/WorkOS authentication isn't supported by this endpoint |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'SSO' has no definition.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

- Create fern/apis/fern-docs-mcp/openapi.json with OpenAPI 3.1.0 spec
- Add generators.yml to properly configure the API definition
- Update MCP server documentation to reference the API spec location
- Includes both get-jwt and search/v2/key endpoints with full specifications

Co-Authored-By: [email protected] <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant